package cn.itcast.util;

import java.util.Calendar;
import java.util.Date;

public class DateTimeUtil {
    //开市时间
    public static long openTime = 0;
    //闭市时间
    public static long closeTime = 0;

    static {

        //1.新建Calendar对象，设置日期
        Calendar calendar = Calendar.getInstance();
        //2.设置开市时间
        //设置日
        calendar.setTime(new Date());
        //设置小时
        calendar.set(Calendar.HOUR_OF_DAY, 0);
        //设置分钟
        calendar.set(Calendar.MINUTE, 0);
        //设置秒
        calendar.set(Calendar.SECOND, 0);
        //设置毫秒
        calendar.set(Calendar.MILLISECOND, 0);
        //获取开市时间
        openTime = calendar.getTime().getTime();

        //3.设置闭市时间
        calendar.set(Calendar.HOUR_OF_DAY, 23);
        calendar.set(Calendar.MINUTE, 59);

        //获取闭市时间
        closeTime = calendar.getTime().getTime();
    }

    public static void main(String[] args) {
        System.out.println(openTime);
        System.out.println(closeTime);
    }
}
